//
//  ZUserInfoModel.swift
//  swift-weibo
//
//  Created by zero on 17/3/23.
//  Copyright © 2017年 zero. All rights reserved.
//

import UIKit

private let access_Token = "access_token"
private let expires_Date = "expires_date"
private let remind_In = "remind_in"
private let uId = "uId"
private let avatar_Large = "avatar_large"

class ZUserInfoModel: NSObject,NSCoding {

    //  用户登录令牌

    var access_token:String?
    
    //  令牌的声明周期
    var expires_in: TimeInterval = 0 {
        
        didSet{
            
            expires_date = Date(timeIntervalSinceNow: expires_in)
        }
    }
    
    //  
    var remind_in:String?
    
    var name:String?
    var uid:String?
    
    var avatar_large:String?
    
    var expires_date: Date?
    
    init(dic:[String : Any]){
    
        super.init()
        
        self.setValuesForKeys(dic)
    
    }
    
    func encode(with aCoder: NSCoder) {
        
        aCoder.encode(access_token, forKey: access_Token)
        aCoder.encode(expires_date, forKey: expires_Date)
        aCoder.encode(remind_in, forKey: remind_In)
        aCoder.encode(uid, forKey: uId)
        aCoder.encode(avatar_large, forKey: avatar_Large)
    }
    
    required init?(coder aDecoder: NSCoder) {
        
        access_token = aDecoder.decodeObject(forKey: access_Token) as? String
        expires_date = aDecoder.decodeObject(forKey: expires_Date) as? Date
        uid = aDecoder.decodeObject(forKey: uId) as? String
        avatar_large = aDecoder.decodeObject(forKey: avatar_Large) as? String
        
        
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
        
    }
    
    
}
